package educationaladministrationsystem.CSM.Mapper.StudentAndTeacher.Teacher;

import educationaladministrationsystem.Class.Course;
import educationaladministrationsystem.Class.Student;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface TeacherSupplementalGradesMapper {
    @Select("select * from course where teacher=#{id}")
    List<Course> getAllCourse(String id);

    @Select("select count(*) from studentwithcourse where classId=#{id} and GPA is not null")
    Integer getHaveSupplePeople(String id);

    @Select("select *,GPA,CPA from student,studentwithcourse where classId=#{id} and student.id=studentwithcourse.studentId limit #{page},#{pageNumber}")
    List<Student> getAllStudentInformationByClassId(String id, int page, int pageNumber);

    @Update("update studentwithcourse set GPA=#{credit},CPA=#{allCredit} where classId=#{classId} and studentId=#{studentId}")
    void uploadCredit(String classId, String studentId, double credit, double allCredit);

    @Select("select count(*) from studentwithcourse where classId=#{id}")
    int getCountFromStudentWithCourse(String id);

    @Select("select count(distinct classId) from studentwithcourse where classId in (select classId from course where teacher=#{id})")
    int getAllCourseCount(String id);

    @Select("select count(distinct classId) from studentwithcourse where GPA is not null and classId in (select classId from course where teacher = #{id})")
    int haveSuppleCourseCount(String id);
}
